﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.IO;

public partial class Pages_AddEvent : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        rpPlace.DataSource = GetFiles("place");
        rpPlace.DataBind();

        rpEvent.DataSource = GetFiles("event");
        rpEvent.DataBind();

        rpCountry.DataSource = GetFiles("countries");
        rpCountry.DataBind();

        rpActivity.DataSource = GetFiles("activity");
        rpActivity.DataBind();

        rpPeople.DataSource = GetFiles("people");
        rpPeople.DataBind();
    }

    public void rp1_dataBound(object sender, EventArgs e)
    {

    }

    public DataTable GetFiles(string folder)
    {
        DataTable dt2 = new DataTable();
        dt2.Columns.Add("id");
        FileInfo fi = new FileInfo(Server.MapPath("~/Objects/" + folder + "/"));
        DirectoryInfo di = fi.Directory;
        FileInfo[] fsi = di.GetFiles();
        //Response.Write("The directory contains the following files and directories:" + di.FullName + "<hr>");
        foreach (FileSystemInfo info in fsi)
        {
            DataRow dr2 = dt2.NewRow();
            dr2[0] = info.Name;
            dt2.Rows.Add(dr2);
        }

        return dt2;
    }
}